﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Collections;
using log4net;
using WEB.BLL.Entities;
using WEB.Exceptions;

namespace WEB.BLL.Services
{
    #region RoleService

    /// <summary>
    /// RoleService object for Ibatis mapped table 'Role'.
    /// </summary>
    public class RoleService : IRoleService
    {
        private static readonly ILog log = LogManager.GetLogger(typeof(RoleService).Name);
        private static volatile RoleService _RoleService = null;
        public static RoleService GetInstance()
        {
            if (_RoleService == null)
            {
                lock (typeof(RoleService))
                {
                    if (_RoleService == null) // double-check
                        _RoleService = new RoleService();
                }
            }
            return _RoleService;
        }
        public RoleService()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public IList<RoleEntity> Find(RoleEntity obj)
        {
            try
            {
                IList<RoleEntity> resul = ExecuteQueryForList<RoleEntity>("RoleSearch", obj);
                return resul;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        public IList<RoleEntity> LoadAllParam(RoleEntity obj)
        {
            try
            {
                IList<RoleEntity> resul = ExecuteQueryForList<RoleEntity>("RoleLoadAllParam", obj);
                return resul;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
        public int UpdateCheck(RoleEntity objE)
        {
            try
            {
                ExecuteUpdate("RoleUpdateCheck", objE);
                return 1;
            }
            catch (Exception ex)
            {
                log.Debug(ex.Message);
                throw new DBException(ex.Message, ex);
            }
        }
    }
    #endregion
}
